/**
 * 
 */
package cz.cvut.fit.bugtrac.manager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cz.cvut.fit.bugtrac.dao.GraphDAO;
import cz.cvut.fit.bugtrac.datacollector.DataCollector;
import cz.cvut.fit.bugtrac.exception.BugTracException;
import cz.cvut.fit.bugtrac.persistence.Graph;
import cz.cvut.fit.bugtrac.publicmodel.dto.graph.GraphDTO;
import cz.cvut.fit.bugtrac.util.DozerUtil;

/**
 * @author Jarec
 * 
 */
@Component
public class DataCollectionManagerImpl implements DataCollectionManager {

	private DataCollector dataCollector;
	private GraphDAO graphDAO;
	private DozerUtil dozerUtil;

	/*
	 * (non-Javadoc)
	 * 
	 * @see cz.cvut.fit.bugtrac.manager.DataCollectionManager#collectData()
	 */
	@Override
	public void collectData() throws BugTracException {
		GraphDTO graphDTO = dataCollector.collectsData();
		graphDAO.save(dozerUtil.mapObject(graphDTO, Graph.class));
	}

	/**
	 * @return the dataCollector
	 */
	public DataCollector getDataCollector() {
		return dataCollector;
	}

	/**
	 * @param dataCollector
	 *            the dataCollector to set
	 */
	@Autowired
	public void setDataCollector(DataCollector dataCollector) {
		this.dataCollector = dataCollector;
	}

	/**
	 * @return the graphDAO
	 */
	public GraphDAO getGraphDAO() {
		return graphDAO;
	}

	/**
	 * @param graphDAO
	 *            the graphDAO to set
	 */
	@Autowired
	public void setGraphDAO(GraphDAO graphDAO) {
		this.graphDAO = graphDAO;
	}

	/**
	 * @return the dozerUtil
	 */
	public DozerUtil getDozerUtil() {
		return dozerUtil;
	}

	/**
	 * @param dozerUtil
	 *            the dozerUtil to set
	 */
	@Autowired
	public void setDozerUtil(DozerUtil dozerUtil) {
		this.dozerUtil = dozerUtil;
	}

}
